﻿using System;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Security.Principal;
using System.Web;

namespace NWebMock
{
    public interface IHttpApplication : IHttpAsyncHandler, IHttpHandler, IComponent, IDisposable
    {
        #region Properties

        /// <summary>
        /// Gets the current state of an application.
        /// </summary>
        IHttpApplicationState Application { get; }

        /// <summary>
        /// Gets HTTP-specific information about the current request.
        /// </summary>
        IHttpContext Context { get; }

        /// <summary>
        /// Gets the collection of modules for the current application.
        /// </summary>
        IHttpModuleCollection Modules { get; }

        /// <summary>
        /// Gets the intrinsic request object for the current request.
        /// </summary>
        IHttpRequest Request { get; }

        /// <summary>
        /// Gets the intrinsic response object for the current request.
        /// </summary>
        IHttpResponse Response { get; }

        /// <summary>
        /// Gets the intrinsic server object for the current request.
        /// </summary>
        IHttpServerUtility Server { get; }

        /// <summary>
        /// Gets the intrinsic session object that provides access to session data.
        /// </summary>
        IHttpSessionState Session { get; }

        /// <summary>
        /// Gets the intrinsic user object for the current request.
        /// </summary>
        IPrincipal User { get; }

        #endregion

        #region Methods

        /// <summary>
        /// Adds the specified AcquireRequestState event to the collection of asynchronous AcquireRequestState event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the AcquireRequestState.</param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the AcquireRequestState.</param>
        void AddOnAcquireRequestStateAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified AcquireRequestState event to the collection of asynchronous AcquireRequestState event handlers for the current request.
        /// </summary>
        /// <param name="beginHandler">The BeginEventHandler that starts asynchronous processing of the AcquireRequestState.</param>
        /// <param name="endHandler">The EndEventHandler that ends asynchronous processing of the AcquireRequestState.</param>
        /// <param name="state">The associated state to add to the asynchronous AcquireRequestState.</param>
        void AddOnAcquireRequestStateAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, Object state);

        /// <summary>
        /// Adds the specified AuthenticateRequest event to the collection of asynchronous AuthenticateRequest event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the AuthenticateRequest. </param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the AuthenticateRequest. </param>
        void AddOnAuthenticateRequestAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified AuthenticateRequest event to the collection of asynchronous AuthenticateRequest event handlers for the current request.
        /// </summary>
        /// <param name="beginHandler">The BeginEventHandler that starts asynchronous processing of the AuthenticateRequest.</param>
        /// <param name="endHandler">The EndEventHandler that ends asynchronous processing of the AuthenticateRequest.</param>
        /// <param name="state">The associated state to add to the asynchronous AuthenticateRequest.</param>
        void AddOnAuthenticateRequestAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, Object state);

        /// <summary>
        /// Adds the specified AuthorizeRequest event to the collection of asynchronous AuthorizeRequest event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the AuthorizeRequest.</param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the AuthorizeRequest.</param>
        void AddOnAuthorizeRequestAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified AuthorizeRequest event to the collection of asynchronous AuthorizeRequest event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the AuthorizeRequest.</param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the AuthorizeRequest.</param>
        /// <param name="state">The associated state to add to the asynchronous AcquireRequestState.</param>
        void AddOnAuthorizeRequestAsync(BeginEventHandler bh, EndEventHandler eh, Object state);

        /// <summary>
        /// Adds the specified EndRequest event to the collection of asynchronous EndRequest event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the EndRequest. </param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the EndRequest. </param>
        void AddOnEndRequestAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified EndRequest event to the collection of asynchronous EndRequest event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the EndRequest. </param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the EndRequest. </param>
        /// <param name="state">The associated state to add to the asynchronous EndRequest.</param>
        void AddOnEndRequestAsync(BeginEventHandler bh, EndEventHandler eh, Object state);

        /// <summary>
        /// Adds the specified LogRequest event to the collection of asynchronous LogRequest event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the LogRequest.</param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the LogRequest.</param>
        void AddOnLogRequestAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified LogRequest event to the collection of asynchronous LogRequest event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the LogRequest.</param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the LogRequest.</param>
        /// <param name="state">The associated state to add to the asynchronous LogRequest.</param>
        void AddOnLogRequestAsync(BeginEventHandler bh, EndEventHandler eh, Object state);

        /// <summary>
        /// Adds the specified MapRequestHandler event to the collection of asynchronous MapRequestHandler event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the MapRequestHandler.</param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the MapRequestHandler.</param>
        void AddOnMapRequestHandlerAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified MapRequestHandler event to the collection of asynchronous MapRequestHandler event handlers for the current request.
        /// </summary>
        /// <param name="beginHandler">The BeginEventHandler that starts asynchronous processing of the MapRequestHandler.</param>
        /// <param name="endHandler">The EndEventHandler that ends asynchronous processing of the MapRequestHandler.</param>
        /// <param name="state">The associated state to add to the asynchronous MapRequestHandler.</param>
        void AddOnMapRequestHandlerAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, Object state);

        /// <summary>
        /// Adds the specified PostAcquireRequestState event to the collection of asynchronous PostAcquireRequestState event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the PostAcquireRequestState. </param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the PostAcquireRequestState. </param>
        void AddOnPostAcquireRequestStateAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified PostAcquireRequestState event to the collection of asynchronous PostAcquireRequestState event handlers for the current request.
        /// </summary>
        /// <param name="beginHandler">The BeginEventHandler that starts asynchronous processing of the PostAcquireRequestState. </param>
        /// <param name="endHandler">The EndEventHandler that ends asynchronous processing of the PostAcquireRequestState. </param>
        /// <param name="state">The associated state to add to the asynchronous PostAcquireRequestState.</param>
        void AddOnPostAcquireRequestStateAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, Object state);

        /// <summary>
        /// Adds the specified PostAuthenticateRequest event to the collection of asynchronous PostAuthenticateRequest event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the PostAuthenticateRequest. </param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the PostAuthenticateRequest. </param>
        void AddOnPostAuthenticateRequestAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified PostAuthorizeRequest event to the collection of asynchronous PostAuthorizeRequest event handlers for the current request.
        /// </summary>
        /// <param name="beginHandler">The BeginEventHandler that starts asynchronous processing of the PostAuthorizeRequest. </param>
        /// <param name="endHandler">The EndEventHandler that ends asynchronous processing of the PostAuthorizeRequest. </param>
        /// <param name="state">The associated state to add to the asynchronous PostAuthorizeRequest.</param>
        void AddOnPostAuthenticateRequestAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, Object state);

        /// <summary>
        /// Adds the specified PostAuthorizeRequest event to the collection of asynchronous PostAuthorizeRequest event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the PostAuthorizeRequest. </param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the PostAuthorizeRequest. </param>
        void AddOnPostAuthorizeRequestAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified PostAuthorizeRequest to the collection of asynchronous PostAuthorizeRequest event handlers for the current request.
        /// </summary>
        /// <param name="beginHandler">The BeginEventHandler that starts asynchronous processing of the PostAuthorizeRequest. </param>
        /// <param name="endHandler">The EndEventHandler that ends asynchronous processing of the PostAuthorizeRequest. </param>
        /// <param name="state">The associated state to add to the asynchronous PostAuthorizeRequest.</param>
        void AddOnPostAuthorizeRequestAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, Object state);

        /// <summary>
        /// Adds the specified PostLogRequest event to the collection of asynchronous PostLogRequest event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the PostLogRequest.</param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the PostLogRequest.</param>
        void AddOnPostLogRequestAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified PostLogRequest event to the collection of asynchronous PostLogRequest event handlers for the current request.
        /// </summary>
        /// <param name="beginHandler">The BeginEventHandler that starts asynchronous processing of the PostLogRequest.</param>
        /// <param name="endHandler">The EndEventHandler that ends asynchronous processing of the PostLogRequest.</param>
        /// <param name="state">The associated state to add to the asynchronous PostLoqRequest().</param>
        void AddOnPostLogRequestAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, Object state);

        /// <summary>
        /// Adds the specified PostMapRequestHandler event to the collection of asynchronous PostMapRequestHandler event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the PostMapRequestHandler. </param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the PostMapRequestHandler. </param>
        void AddOnPostMapRequestHandlerAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified PostMapRequestHandler event to the collection of asynchronous PostMapRequestHandler event handlers for the current request.
        /// </summary>
        /// <param name="beginHandler">The BeginEventHandler that starts asynchronous processing of the PostMapRequestHandler. </param>
        /// <param name="endHandler">The EndEventHandler that ends asynchronous processing of the PostMapRequestHandler. </param>
        /// <param name="state">The associated state to add to the asynchronous PostMapRequestHandler collection.</param>
        void AddOnPostMapRequestHandlerAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, Object state);

        /// <summary>
        /// Adds the specified PostReleaseRequestState event to the collection of asynchronous PostReleaseRequestState event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the PostReleaseRequestState. </param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the PostReleaseRequestState. </param>
        void AddOnPostReleaseRequestStateAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified PostReleaseRequestState event to the collection of asynchronous PostReleaseRequestState event handlers for the current request.
        /// </summary>
        /// <param name="beginHandler">The BeginEventHandler that starts asynchronous processing of the PostReleaseRequestState. </param>
        /// <param name="endHandler">The EndEventHandler that ends asynchronous processing of the PostReleaseRequestState. </param>
        /// <param name="state">The associated state to add to the asynchronous PostReleaseRequestState.</param>
        void AddOnPostReleaseRequestStateAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, Object state);

        /// <summary>
        /// Adds the specified PostRequestHandlerExecute event to the collection of asynchronous PostRequestHandlerExecute event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the PostRequestHandlerExecute. </param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the PostRequestHandlerExecute. </param>
        void AddOnPostRequestHandlerExecuteAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified PostRequestHandlerExecute event to the collection of asynchronous PostRequestHandlerExecute event handlers for the current request.
        /// </summary>
        /// <param name="beginHandler">The BeginEventHandler that starts asynchronous processing of the PostRequestHandlerExecute. </param>
        /// <param name="endHandler">The EndEventHandler that ends asynchronous processing of the PostRequestHandlerExecute. </param>
        /// <param name="state">The associated state to add to the asynchronous PostRequestHandlerExecute.</param>
        void AddOnPostRequestHandlerExecuteAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, Object state);

        /// <summary>
        /// Adds the specified PostResolveRequestCache event to the collection of asynchronous PostResolveRequestCache event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the PostResolveRequestCache. </param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the PostResolveRequestCache. </param>
        void AddOnPostResolveRequestCacheAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified PostResolveRequestCache event to the collection of asynchronous PostResolveRequestCache event handlers for the current request.
        /// </summary>
        /// <param name="beginHandler">The BeginEventHandler that starts asynchronous processing of the PostResolveRequestCache. </param>
        /// <param name="endHandler">The EndEventHandler that ends asynchronous processing of the PostResolveRequestCache. </param>
        /// <param name="state">The associated state to add to the asynchronous PostResolveRequestCache.</param>
        void AddOnPostResolveRequestCacheAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, Object state);

        /// <summary>
        /// Adds the specified PostUpdateRequestCache event to the collection of asynchronous PostUpdateRequestCache event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the PostUpdateRequestCache. </param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the PostUpdateRequestCache. </param>
        void AddOnPostUpdateRequestCacheAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified PostUpdateRequestCache event to the collection of asynchronous PostUpdateRequestCache event handlers for the current request.
        /// </summary>
        /// <param name="beginHandler">The BeginEventHandler that starts asynchronous processing of the event. </param>
        /// <param name="endHandler">The EndEventHandler that ends asynchronous processing of the PostUpdateRequestCache. </param>
        /// <param name="state">The associated state to add to the asynchronous PostUpdateRequestCache.</param>
        void AddOnPostUpdateRequestCacheAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, Object state);

        /// <summary>
        /// Adds the specified PreRequestHandlerExecute event to the collection of asynchronous PreRequestHandlerExecute event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the PreRequestHandlerExecute. </param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the PreRequestHandlerExecute. </param>
        void AddOnPreRequestHandlerExecuteAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified PreRequestHandlerExecute event to the collection of asynchronous PreRequestHandlerExecute event handlers for the current request.
        /// </summary>
        /// <param name="beginHandler">The BeginEventHandler that starts asynchronous processing of the PreRequestHandlerExecute. </param>
        /// <param name="endHandler">The EndEventHandler that ends asynchronous processing of the PreRequestHandlerExecute. </param>
        /// <param name="state">The associated state to add to the asynchronous PreRequestHandlerExecute collection.</param>
        void AddOnPreRequestHandlerExecuteAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, Object state);

        /// <summary>
        /// Adds the specified ReleaseRequestState event to the collection of asynchronous ReleaseRequestState event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the ReleaseRequestState. </param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the ReleaseRequestState. </param>
        void AddOnReleaseRequestStateAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified ReleaseRequestState event to the collection of asynchronous ReleaseRequestState event handlers for the current request.
        /// </summary>
        /// <param name="beginHandler">The BeginEventHandler that starts asynchronous processing of the ReleaseRequestState. </param>
        /// <param name="endHandler">The EndEventHandler that ends asynchronous processing of the ReleaseRequestState. </param>
        /// <param name="state">The associated state to add to the asynchronous ReleaseRequestState.</param>
        void AddOnReleaseRequestStateAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, Object state);

        /// <summary>
        /// Adds the specified ResolveRequestCache event handler to the collection of asynchronous ResolveRequestCache event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the ResolveRequestCache. </param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the ResolveRequestCache. </param>
        void AddOnResolveRequestCacheAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified ResolveRequestCache event handler to the collection of asynchronous ResolveRequestCache event handlers for the current request.
        /// </summary>
        /// <param name="beginHandler">The BeginEventHandler that starts asynchronous processing of the ResolveRequestCache. </param>
        /// <param name="endHandler">The EndEventHandler that ends asynchronous processing of the ResolveRequestCache. </param>
        /// <param name="state">The associated state to add to the asynchronous ResolveRequestCache.</param>
        void AddOnResolveRequestCacheAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, Object state);

        /// <summary>
        /// Adds the specified UpdateRequestCache event to the collection of asynchronous UpdateRequestCache event handlers for the current request.
        /// </summary>
        /// <param name="bh">The BeginEventHandler that starts asynchronous processing of the UpdateRequestCache. </param>
        /// <param name="eh">The EndEventHandler that ends asynchronous processing of the UpdateRequestCache. </param>
        void AddOnUpdateRequestCacheAsync(BeginEventHandler bh, EndEventHandler eh);

        /// <summary>
        /// Adds the specified UpdateRequestCache event to the collection of asynchronous UpdateRequestCache event handlers for the current request.
        /// </summary>
        /// <param name="beginHandler">The BeginEventHandler that starts asynchronous processing of the UpdateRequestCache. </param>
        /// <param name="endHandler">The EndEventHandler that ends asynchronous processing of the UpdateRequestCache. </param>
        /// <param name="state">The associated state to add to the asynchronous UpdateRequestCache.</param>
        void AddOnUpdateRequestCacheAsync(BeginEventHandler beginHandler, EndEventHandler endHandler, Object state);

        /// <summary>
        /// Causes ASP.NET to bypass all events and filtering in the HTTP pipeline chain of execution and directly execute the EndRequest event.
        /// </summary>
        void CompleteRequest();

        /// <summary>
        /// Provides an application-wide implementation of the VaryByCustom property.
        /// </summary>
        /// <param name="context">An HttpContext object that contains information about the current Web request. </param>
        /// <param name="custom">The custom string that specifies which cached response is used to respond to the current request. </param>
        /// <returns>If the value of the custom parameter is "browser", the browser's Type; otherwise, null.</returns>
        string GetVaryByCustomString(HttpContext context, string custom);

        /// <summary>
        /// Executes custom initialization code after all event handler modules have been added.
        /// </summary>
        void Init();

        #endregion
    }
}
